<template>
	<view class="u-demo">
		<view class="u-demo-title">
			{{content.name}}
		</view>
		<image :src="base+content.imgUrl" mode="" style="width: 100%;"></image>
		<uni-card>
			<view class="" v-html="content.content">

			</view>
		</uni-card>
		<uni-group title="推荐活动">
			<uni-card :title="item.title" v-for="(item,index) in list" @click="click(item.id)">
				<image :src="base+item.imgUrl" mode="" style="width: 100%;"></image>
				<view>报名人数：{{item.signupNum}}</view>
				<view>点赞数：{{item.likeNum}}</view>
				<view>发布时间：{{item.publishTime}}</view>
			</uni-card>
		</uni-group>
		<uni-group :title="'全部评论('+commentList.length+')'">
			<uni-card>
				<view class="comment" v-for="(res, index) in commentList" :key="res.id">
					<view class="left">
						<image :src="base+res.avatar" mode="aspectFill"></image>
					</view>
					<view class="right">
						<view class="top">
							<view class="name">{{ res.nickName }}</view>

						</view>
						<view class="content">{{ res.content }}</view>

						<view class="bottom">
							{{ res.commentTime }}
							<view class="reply">回复</view>
						</view>
					</view>
				</view>
			</uni-card>
		</uni-group>
		<view style="height: 20vh;"></view>
		<uni-group style="position: fixed;bottom: 0%;right: 0%;left: 0%;z-index: 99;">
			<view class="u-flex">
				<uni-easyinput v-model="value"></uni-easyinput>
				<button type="primary" class="u-m-l-10" @click="da">发送</button>
			</view>
		</uni-group>
	</view>
</template>

<script>
	import api from 'commer/apiURL.js'
	export default {
		data() {
			return {
				base: api.baseurl,
				content: '',
				commentList: [],
				list: [],
				id:'',
				value:''
			}
		},
		onLoad(options) {
			this.getlun(options.id)
			this.getlun2(options.id)
			this.getlun3()
			this.id = options.id
		},
		methods: {
			da(){
				this.$post(this.base+'/prod-api/api/activity/comment',{
					"activityId": this.id,
					"content": this.value
				}).then((res)=>{
					if(res.code == 200){
						uni.showToast({
							title:'评论成功'
						})
						this.value = ''
						this.getlun2(this.id)
					}else{
						uni.showToast({
							title:res.msg,
							icon:'none'
						})
					}
				})
			},
			getlun3() {
				this.$get(this.base + '/prod-api/api/activity/activity/list',{
					recommend:'Y'
				}).then((res) => {
					this.list = res.rows.slice(0,2)
				})
			},
			getlun(id) {
				this.$get(this.base + '/prod-api/api/activity/activity/' + id).then((res) => {
					this.content = res.data
				})
			},
			getlun2(id) {
				this.$get(this.base + '/prod-api/api/activity/comment/list', {
					activityId: id
				}).then((res) => {
					this.commentList = res.rows
				})
			}
		}
	}
</script>

<style>

</style>
<style lang="scss" scoped>
	.comment {
		display: flex;
		padding: 30rpx;

		.left {
			image {
				width: 64rpx;
				height: 64rpx;
				border-radius: 50%;
				background-color: #f2f2f2;
			}
		}

		.right {
			flex: 1;
			padding-left: 20rpx;
			font-size: 30rpx;

			.top {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-bottom: 10rpx;

				.name {
					color: #5677fc;
				}

				.like {
					display: flex;
					align-items: center;
					color: #9a9a9a;
					font-size: 26rpx;

					.num {
						margin-right: 4rpx;
						color: #9a9a9a;
					}
				}

				.highlight {
					color: #5677fc;

					.num {
						color: #5677fc;
					}
				}
			}

			.content {
				margin-bottom: 10rpx;
			}

			.reply-box {
				background-color: rgb(242, 242, 242);
				border-radius: 12rpx;

				.item {
					padding: 20rpx;
					border-bottom: solid 2rpx $u-border-color;

					.username {
						font-size: 24rpx;
						color: #999999;
					}
				}

				.all-reply {
					padding: 20rpx;
					display: flex;
					color: #5677fc;
					align-items: center;

					.more {
						margin-left: 6rpx;
					}
				}
			}

			.bottom {
				margin-top: 20rpx;
				display: flex;
				font-size: 24rpx;
				color: #9a9a9a;

				.reply {
					color: #5677fc;
					margin-left: 10rpx;
				}
			}
		}
	}
</style>
